package sample.reflects;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;

public class helloMethodCls {
	public static void main(String[] args) {
		Class<?> demo = null;

		try {
			demo = Class.forName("sample.reflects.Person2");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		Method method[] = demo.getMethods();
		for(int i=0;i<method.length;++i){
			Class<?> returnType=method[i].getReturnType();
			Class<?> para[]=method[i].getParameterTypes();
			int temp=method[i].getModifiers();
			System.out.println(Modifier.toString(temp)+" ");
			System.out.println(returnType.getName()+"  ");
			System.out.println(method[i].getName()+" ");
			System.out.println("(");
			for(int j=0;j<para.length;++j){
				System.out.print(para[j].getName()+" args"+j);
				if(j<para.length-1){
					System.out.print(",");
				}
			}
			
			Class<?> exec[] =method[i].getExceptionTypes();
			if(exec.length>0){
				System.out.println(") throws ");
				for(int k=0;k<exec.length;++k){
					System.out.println(exec[k].getName()+" ");
					if(k<exec.length-1){
						System.out.println(",");
					}
				}
			}else{
				System.out.println(")");
			}
			
			System.out.println();
		}

	}

}
